package com.ruitu.health_2.ui.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ruitu.arad.base.base_list.ListBaseAdapter;
import com.ruitu.arad.base.base_list.SuperViewHolder;
import com.ruitu.health_2.R;
import com.ruitu.router_module.bean.article.Article;
import com.ruitu.router_module.util.GlideUtil;

public class ArticleListAdapter extends ListBaseAdapter<Article> {
    public ArticleListAdapter(Context context) {
        super(context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_article_list;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        ImageView icon = holder.getView(R.id.icon);// 图片
        TextView tv_title = holder.getView(R.id.tv_title);// 标题
        TextView tv_name = holder.getView(R.id.tv_name);// 艺术家
        TextView tv_time = holder.getView(R.id.tv_time);// 时间
        TextView tv_subtitle = holder.getView(R.id.tv_subtitle);// 简介

        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) icon.getLayoutParams();
        params.width = params.height * 16 / 12;
        icon.setLayoutParams(params);

        Article article = mDataList.get(position);
        tv_title.setText(article.getTitle());
        tv_name.setText("" + article.getArtName());
        try {
//            tv_time.setText(article.getUpdateTime());
        } catch (Exception e) {
            tv_time.setText("");
        }
        tv_subtitle.setText(article.getReserveOne());

        GlideUtil.loadImg(article.getSmallImg(), icon);
    }
}
